package com.zhou.javase.api;

import java.util.Arrays;
	

/**
 * 冒泡排序的测试   
 * 双重for循环
 * 内循环执行几次
 * 两值交换，需要借助第三方变量
 * 
 * @author lenovo
 *
 */
public class BubbleSort
{
	public static void main(String[] args)
	{
		int[] arr = { 1, 13, 8, 7};

		for (int i = 0; i < arr.length; i++)
		{
			for (int j = i+1; j < arr.length; j++)
			{
				System.out.println(i + "---下标值->" + j + ";" + arr[i] + "--内容->" +arr[j]);
				if (arr[i] > arr[j])
				{
					int tmp = arr[i];
					arr[i] = arr[j];
					arr[j] = tmp;
				}
			}
		}

		System.out.println("the max is " + arr[arr.length-1]);
		System.out.println(Arrays.toString(arr));
		System.out.println("=================");
		int a = 10 ; 
		int b = 20 ; 
		System.out.println("a=" + a +";b=" + b);
		int c = 0; 
		c = a ;
		a = b ; 
		b = c ; 
		System.out.println("a=" + a +";b=" + b);
	}

}
